package com.caocaog.market.data.transfer.controller;

import com.caocaog.market.data.transfer.service.MkTestService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.ResultSet;

/**
 * @author liguang
 * @version 1.0.0
 * @Project jeecg-boot
 * @Package com.caocaog.market.data.transfer.controller
 * @ClassName TestController.java
 * @createTime 2022年01月06日 18:18:00
 * @Description 数据转移类，包含：商家、门店、商品、订单
 */
@RestController
@RequestMapping("/part/data/transfer/")
@Slf4j
@SuppressWarnings("all")
public class TestController {
    @Autowired
    private MkTestService testService;
    @RequestMapping("merchant")
    public Result transferMerchant(){
        Result relt = new Result();
        String msg = testService.insertMerchant();
        relt.success(msg);
        return relt;
    }
    @RequestMapping("shop")
    public Result transferShop(){
        Result relt = new Result();
        String msg = testService.insertShop();
        relt.success(msg);
        return relt;
    }
    // 转移商品分类
    @RequestMapping("classify")
    public Result transferClassify(){
        Result relt = new Result();
        String msg = testService.pullClassify();
        relt.success(msg);
        return relt;
    }
    // 转移商品数据
    @RequestMapping("goods")
    public Result transferGoods(){
        Result relt = new Result();
        String msg = testService.pullGoods();
        relt.success(msg);
        return relt;
    }
    // 更新商品历史表中的goods_attribute字段和goods_specifications字段
    @RequestMapping("updateGoodsHis")
    public Result updateGoodsHis(){
        Result relt = new Result();
        String msg = testService.updateGoodsHis();
        relt.success(msg);
        return relt;
    }
    // 转移订单数据
    @RequestMapping("order")
    public Result transferOrder(){
        Result relt = new Result();
        String msg = testService.pullOrder();
        relt.success(msg);
        return relt;
    }

    // 更改商家用户的密码
//    String salt = oConvertUtils.randomGen(8);
//                sysUser.setSalt(salt);
//                sysUser.setPassword(PasswordUtil.encrypt(sysUser.getUsername(), "caocao123", salt));

    // 转移订单数据
    @RequestMapping("updatePassword")
    public Result updatePassword(){
        Result relt = new Result();
        String msg = testService.updatePassword();
        relt.success(msg);
        return relt;
    }


    // 更改商品原价和商品现价
    @RequestMapping("updGoodsSorts")
    public Result updGoodsSort(){
        Result relt = new Result();
        String msg = testService.updGoodsSortsFromCcpt();
        relt.success(msg);
        return relt;
    }
    // 更新门店的省、市、县
    @RequestMapping("updShopArea")
    public Result updShopArea(){
        Result relt = new Result();
        String msg = testService.updArea();
        relt.success(msg);
        return relt;
    }

}
